#include <iostream>
#include <pthread.h>

namespace MutexData
{
	class Mutex
	{
	public:
		Mutex(const Mutex &) = delete;
		Mutex &operator=(const Mutex &) = delete;
		Mutex()
		{
			pthread_mutex_init(&_mutex, nullptr);
		}
		void Lock()
		{
			pthread_mutex_lock(&_mutex);
		}
		void UnLock()
		{
			pthread_mutex_unlock(&_mutex);
		}
		~Mutex()
		{
			pthread_mutex_destroy(&_mutex);
		}

	private:
		pthread_mutex_t _mutex;
	};

	class LockGuard
	{
	public:
		LockGuard(Mutex &Lock):_Lock(Lock)
		{
			_Lock.Lock();
		}
		~LockGuard()
		{
			_Lock.UnLock();
		}
	private:
		Mutex &_Lock;
    };
}